/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    usart.h
  * @brief   This file contains all the function prototypes for
  *          the usart.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern UART_HandleTypeDef huart1;

extern UART_HandleTypeDef huart2;

/* USER CODE BEGIN Private defines */
typedef enum
{
    UART_ID_SENSOR = 0,
    UART_ID_MODBUS,
    UART_ID_NUM
}uart_id_e_t;

#define USART_BUFF_SIZE         (128)
typedef struct
{
	uint8_t rx_buf[USART_BUFF_SIZE];
	uint8_t tx_buf[USART_BUFF_SIZE];
	uint16_t rx_len;
	uint16_t tx_len;
} usart_buf_t;

extern usart_buf_t usart_buf[UART_ID_NUM];

typedef int (*uart_rcv_callback)(uint8_t uart_id, uint8_t *buf,uint8_t len);

/* USER CODE END Private defines */

void MX_USART1_UART_Init(void);
void MX_USART2_UART_Init(void);

/* USER CODE BEGIN Prototypes */
//extern uint8_t *dat;
void UART1_SetBaudRate(uint32_t baudrate);

void UART1_SendBytes(uint8_t* data, int size);
void UART2_SendBytes(uint8_t* data, int size);

void SPS30_init(void);
void SPS30_Getdata(uint32_t* PM25µg,uint32_t* PM10µg,uint32_t* PM25cm,uint32_t* PM10cm);

void TB600B_O3_readtype(void);
void TB600B_O3_Getdata(uint16_t* O3_data_ug,uint16_t* O3_data_ppb);

void TB600B_NO2_readtype(void);
void TB600B_NO2_Getdata(uint16_t* NO2_data_ug,uint16_t* NO2_data_ppb);
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __USART_H__ */

